/ Assembly List / LJCNetCommon / LJCCryptography / Encrypt

Namespace - LJCNetCommon


Parameters
plainText - The text value.
key - The encryption key.
initializationVector - The IV value.

Returns

The encrypted byte array.

Syntax

C#
public Byte[] Encrypt(String plainText, Byte[] key, Byte[] initializationVector)

Returns an encrypted byte array from a string value. (E)

Example

C#
MemoryCrypto crypto = new MemoryCrypto();
byte[] key;
byte[] iv;
byte[] cipher;
string text;
        
// Generate the key and initialization vector.
crypto.CryptoType = Crypto_Type.Crypto_Rijndael;
key = crypto.GenerateKey();
iv = crypto.GenerateIV();
        
// Encrypt and convert to Base64.
cipher = crypto.Encrypt(GetPlainText(), key, iv);
text = StringHelper.ByteArrayToBase64(cipher);

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.